package com.voltmao.webpro.utils.file;

import java.io.File;
import java.net.URISyntaxException;

public class FileUtils {

    public static String getWebInfPath(){
        String path ="";
        try {
            path = FileUtils.class.getResource("/").toURI().getPath();
            path = path.substring(0, path.lastIndexOf("WEB-INF"));
        } catch (URISyntaxException e){

        }
        return path;
    }

    /**
     * 创建目录
     * @param path
     */
    public static void createDir(String path) {
        // 判断是否目录
        File file = new File(path);
        if (file.isFile()) {
            String _path = path.substring(0, path.lastIndexOf("/") - 1);
            file = new File(_path);
        }
        if (file.isDirectory()) {
            if (!file.exists()) {
                file.mkdirs();
            }
        } else {
            file.mkdirs();
        }
    }



    public static void main(String[] args) {
        System.out.println(getWebInfPath());
    }
}
